import * as React from 'react';
import * as ReactDOM from 'react-dom';
var $ = require("jquery");
            // info  显示图片控件
var WinMark = React.createClass({
    getDefaultProps: function () {
        return {
           show:false
        }
    },

    render: function () {
        var css = "winmark " + (this.props.show?" ":"hide");
        ////console.log(" .................... winmark say :"+css)
        return (
            <div onClick={this.onClick} className={css}></div>
        );
    }
});



var WarningDialog = React.createClass({
    getDefaultProps: function () {
        return {
           show:true,
           title:"设置个title???????",
           message: "默认信息"
        }
    },

    componentDidMount:function(){
        console.log(111111111111111111111111111111111111111111111111111);
        var $parent = $(ReactDOM.findDOMNode(this));
        var $target = $(".winWarn",$parent);
        var left = ($(window).width()-180-$target.width())/2;
        var top = ($(window).height()-56-$target.height())/2;
        $target.css({
            left:left>0?left:0,
            top:top>0?top:0
        })
    },
    resolve: function() {
        this.props.resolve(this.props.param);
    },

    reject: function() {
        this.props.reject();
    },

    render: function () {
        var css = "winWarn " + (this.props.show?" ":"hide");
        return (
            <div className="temp">
                    <WinMark show={this.props.show} />
                    <div className={css}>
                        <div className="warn-d one">
                            <div className="win-up">
                                <span>{this.props.title}</span><span className="iconfont icon-tabiconclose" onClick={this.reject}></span>
                            </div>
                            <div className="win-content">
                                <p>{this.props.message}</p>
                            </div>
                            <div className="win-btn">
                                <button onClick={this.reject} className="btn btn-success">取消</button>
                                <button onClick={this.resolve}   className="btn btn-success">确定</button>
                            </div>
                        </div>
                    </div>
            </div>
        )
    }
});


module.exports = WarningDialog;
